const app = getApp();
const pageSize = 15;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    empty: false,
    loadmore: false,
    nomore: false,
    isRepair: false,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    this.page = 1;
    this.equipment_number = options.equipment_number;
    this.setData({
      isRepair: options.is_repair == 1 ? true : false
    })
    this.getReplaceRecord();
  },



  getReplaceRecord() {
    let url = "Partner/Equipment/replaceList";
    if (this.data.isRepair) {
      url = "Manage/Equipment/replaceList";
    }
    app.ajax({
      url,
      data: {
        page: this.page,
        pageSize: pageSize,
        equipment_number: this.equipment_number
      },
      success: res => {
        let source = res.data.data;
        let list = this.data.list.concat(source.replaceList);
        this.setData({
          empty: source.count == 0 ? true : false,
          list,
          loadmore: list.length < source.count ? true : false,
          nomore: list.length >= source.count ? true : false,
        })
      },
      error: e => {
        app.showToast("网络错误");
      }
    })
  },
})